<template>
  <div class="personal">
    <!-- 跳转到个人中心中的用户  通过id值来获取 -->
    <router-link :to="'/editUserInfo/'+$route.params.id">
      <div class="profile">
        <!-- <img :src="'http://127.0.0.1:3000'+current.head_img" alt /> -->
        <img :src="current.head_img"  alt />
        <div class="profile-center">
          <div class="name">
            <span
              :class="{
                iconfont: true,
                iconxingbienan: current.gender == 1,
                iconxingbienv: current.gender == 0,
              }"
            ></span>
            {{ current.nickname }}
          </div>
          <!-- <div class="time">{{current.create_date}}</div> -->
          <div class="time">{{current.create_date | dateFormat}}</div>
        </div>
        <span class="iconfont iconjiantou1"></span>
      </div>
    </router-link>
    <hmcell title="我的关注" desc="关注的用户"></hmcell>
    <hmcell title="我的跟贴" desc="跟贴/回复"></hmcell>
    <hmcell title="我的收藏" desc="文章/视频"></hmcell>
    <hmcell title="设置"></hmcell>
  </div>
</template>

<script>
import hmcell from "@/components/hmcell.vue";
import {getUserInfo} from '@/apis/user.js'
// 引入之后可以使用，但是并不是当前组件实例的成员
import axios from '@/utils/myaxios.js'
import { dateFormat } from '@/utils/myfilters.js'
export default {
  data() {
    return {
      current:{}
    }
  },
    filters: {
    dateFormat
  },
  components: {
    hmcell,
  },
  async mounted() {
    console.log(this.$route.params.id);
    let res = await getUserInfo(this.$route.params.id)
    console.log(res)
    if(res.data.message == '获取成功'){
       // 渲染之前，对数据进行改造
      res.data.data.head_img = axios.defaults.baseURL + res.data.data.head_img
      this.current = res.data.data
    }

  },
};
</script>

<style lang='less' scoped>
.personal {
  width: 100vw;
  height: 100vh;
  background-color: #eee;
}
a {
  color: #666;
}
.profile {
  display: flex;
  padding: 20px 10px;
  justify-content: space-between;
  align-items: center;
  border-bottom: 5px #ddd solid;

  img {
    // width: 10 / 360 * 100vw;
    // height: 10 / 360 * 100vw;
    width: 60px;
    height: 60px;
    border-radius: 50%;
  }

  .profile-center {
    flex: 1;
    padding: 0 10px;
  }

  .name {
    span {
      color: #75b9eb;
    }
  }

  .time {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
  }
}
</style>
